#include <stdio.h>
#include <string.h>

int dx[] = {0,  1, 1, 1,  0, 0, 0, -1, -1, -1};
int dy[] = {0, -1, 0, 1, -1, 0, 1, -1,  0,  1};

void tr(int x, int y) {
  putchar('0' + (y + 1) + 3 * x);
}

int main() {
  int x, y;
  scanf("%d %d", &x, &y);

  char route[1024];
  scanf("%s", route);

  tr(x, y);
  for (int i = 0; i < strlen(route); i++) {
    x += dx[route[i] - '0'];
    y += dy[route[i] - '0'];
  	tr(x,y);
  }
  
}